package com.jinke.api.modules.app.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum CoinType {

    USDT(0, "美元"),

    CNY(1, "人民币"),
    ;

    @EnumValue
    private final int value;
    private final String desc;

    CoinType(final int value, final String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonValue
    public int getValue() {
        return this.value;
    }

    @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
    public static CoinType defaultEnum(int value) {
        for (CoinType type : CoinType.values()) {
            if (type.getValue() == value) {
                return type;
            }
        }
        throw new IllegalArgumentException("No element matches " + value);
    }
}